class Node:
    def __init__(self, initdata):
        self.data = initdata
        self.next = None

    def getData(self):
        return self.data

    def getNext(self):
        return self.next

    def setData(self, newdata):
        self.data = newdata

    def setNext(self, newnext):
        self.next = newnext

class OrderedList:
    def __init__(self):
        self.head=None

    def add(self,item):
        current=self.head
        previous=None
        stop=False
        while current!=None and not stop:
            if current.getData() >item:
                stop=True
            else:
                previous=current
                current=current.getNext()
        temp=Node(item)
        if previous==None:
            temp.setNext(self.head)
            self.head=temp
        else:
            temp.setNext(current)
            previous.setNext(temp)
    def data(self):
        current = self.head
        lt = []
        while current is not None:
            lt.insert(0,current.getData())
            current = current.getNext()
        return lt[::-1]

lt=list(map(int,input().split()))
o=OrderedList()
for i in range(1,lt[0]+1):
    o.add(lt[i])
m=int(input())
o.add(m)
res=list(set(o.data()))
for i in range(len(res)):
    if i ==len(res)-1:
        print(res[i],end='')
    else:
        print(res[i],end=' ')